package de.htwg_konstanz.infen.aufg3;

import java.io.File;
import java.io.FileNotFoundException;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.io.SAXReader;

public enum Dom4JDocHelper {

	INSTANCE;

	public static Document getDocFromXML(String _xmlPath)
			throws FileNotFoundException, DocumentException {
		File xmlFile = new File(_xmlPath);
		if (!xmlFile.exists())
			throw new FileNotFoundException();
		return (new SAXReader()).read(xmlFile);
	}

	public static Document getDocFromXML(File _xmlFile)
			throws FileNotFoundException, DocumentException {
		if (!_xmlFile.exists())
			throw new FileNotFoundException();
		return (new SAXReader()).read(_xmlFile);
	}

	public static String transform2CustomPath(String _nodePath) {
		String out = _nodePath.replaceAll("/",
				("" + DataGuideHelper.itemSeperator));
		out = out.substring(1);
		return out;
	}

}
